<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - self_test2.info - network_io/unix/socket_util.c</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../index.html">top level</a> - <a href="index.html">network_io/unix</a> - socket_util.c<span style="font-size: 80%;"> (source / <a href="socket_util.c.func.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">self_test2.info</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">17</td>
            <td class="headerCovTableEntry">22</td>
            <td class="headerCovTableEntryMed">77.3 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2011-07-03</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">1</td>
            <td class="headerCovTableEntry">1</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td></td>
            <td></td>
            <td></td>
            <td class="headerItem">Branches:</td>
            <td class="headerCovTableEntry">7</td>
            <td class="headerCovTableEntry">14</td>
            <td class="headerCovTableEntryLo">50.0 %</td>
          </tr>
          <tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">           Branch data     Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>                :            : /* Licensed to the Apache Software Foundation (ASF) under one or more</a>
<span class="lineNum">       2 </span>                :            :  * contributor license agreements.  See the NOTICE file distributed with
<span class="lineNum">       3 </span>                :            :  * this work for additional information regarding copyright ownership.
<span class="lineNum">       4 </span>                :            :  * The ASF licenses this file to You under the Apache License, Version 2.0
<span class="lineNum">       5 </span>                :            :  * (the &quot;License&quot;); you may not use this file except in compliance with
<span class="lineNum">       6 </span>                :            :  * the License.  You may obtain a copy of the License at
<span class="lineNum">       7 </span>                :            :  *
<span class="lineNum">       8 </span>                :            :  *     http://www.apache.org/licenses/LICENSE-2.0
<span class="lineNum">       9 </span>                :            :  *
<span class="lineNum">      10 </span>                :            :  * Unless required by applicable law or agreed to in writing, software
<span class="lineNum">      11 </span>                :            :  * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
<span class="lineNum">      12 </span>                :            :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<span class="lineNum">      13 </span>                :            :  * See the License for the specific language governing permissions and
<span class="lineNum">      14 </span>                :            :  * limitations under the License.
<span class="lineNum">      15 </span>                :            :  */
<span class="lineNum">      16 </span>                :            : 
<span class="lineNum">      17 </span>                :            : #include &quot;apr_network_io.h&quot;
<span class="lineNum">      18 </span>                :            : #include &quot;apr_poll.h&quot;
<a name="19"><span class="lineNum">      19 </span>                :            : </a>
<span class="lineNum">      20 </span>                :            : APR_DECLARE(apr_status_t) apr_socket_atreadeof(apr_socket_t *sock, int *atreadeof)
<span class="lineNum">      21 </span>                :<span class="lineCov">          4 : {</span>
<span class="lineNum">      22 </span>                :            :     apr_pollfd_t pfds[1];
<span class="lineNum">      23 </span>                :            :     apr_status_t rv;
<span class="lineNum">      24 </span>                :            :     apr_int32_t  nfds;
<span class="lineNum">      25 </span>                :            : 
<span class="lineNum">      26 </span>                :            :     /* The purpose here is to return APR_SUCCESS only in cases in
<span class="lineNum">      27 </span>                :            :      * which it can be unambiguously determined whether or not the
<span class="lineNum">      28 </span>                :            :      * socket will return EOF on next read.  In case of an unexpected
<span class="lineNum">      29 </span>                :            :      * error, return that. */
<span class="lineNum">      30 </span>                :            : 
<span class="lineNum">      31 </span>                :<span class="lineCov">          4 :     pfds[0].reqevents = APR_POLLIN;</span>
<span class="lineNum">      32 </span>                :<span class="lineCov">          4 :     pfds[0].desc_type = APR_POLL_SOCKET;</span>
<span class="lineNum">      33 </span>                :<span class="lineCov">          4 :     pfds[0].desc.s = sock;</span>
<span class="lineNum">      34 </span>                :            : 
<span class="lineNum">      35 </span>                :            :     do {
<span class="lineNum">      36 </span>                :<span class="lineCov">          4 :         rv = apr_poll(&amp;pfds[0], 1, &amp;nfds, 0);</span>
<span class="lineNum">      37 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 4 times"> + </span>]:<span class="lineCov">          4 :     } while (APR_STATUS_IS_EINTR(rv));</span>
<span class="lineNum">      38 </span>                :            : 
<span class="lineNum">      39 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          4 :     if (APR_STATUS_IS_TIMEUP(rv)) {</span>
<span class="lineNum">      40 </span>                :            :         /* Read buffer empty -&gt; subsequent reads would block, so,
<span class="lineNum">      41 </span>                :            :          * definitely not at EOF. */
<span class="lineNum">      42 </span>                :<span class="lineCov">          2 :         *atreadeof = 0;</span>
<span class="lineNum">      43 </span>                :<span class="lineCov">          2 :         return APR_SUCCESS;</span>
<span class="lineNum">      44 </span>                :            :     }
<span class="lineNum">      45 </span>        [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 2 times"> + </span>]:<span class="lineCov">          2 :     else if (rv) {</span>
<span class="lineNum">      46 </span>                :            :         /* Some other error -&gt; unexpected error. */
<span class="lineNum">      47 </span>                :<span class="lineNoCov">          0 :         return rv;</span>
<span class="lineNum">      48 </span>                :            :     }
<span class="lineNum">      49 </span>[<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>][<span class="branchCov" title="Branch 2 was taken 2 times"> + </span><span class="branchNoCov" title="Branch 3 was not taken"> - </span>]:<span class="lineCov">          2 :     else if (nfds == 1 &amp;&amp; pfds[0].rtnevents == APR_POLLIN) {</span>
<span class="lineNum">      50 </span>                :            :         apr_sockaddr_t unused;
<span class="lineNum">      51 </span>                :<span class="lineCov">          2 :         apr_size_t len = 1;</span>
<span class="lineNum">      52 </span>                :            :         char buf;
<span class="lineNum">      53 </span>                :            : 
<span class="lineNum">      54 </span>                :            :         /* The socket is readable - peek to see whether it returns EOF
<span class="lineNum">      55 </span>                :            :          * without consuming bytes from the socket buffer. */
<span class="lineNum">      56 </span>                :<span class="lineCov">          2 :         rv = apr_socket_recvfrom(&amp;unused, sock, MSG_PEEK, &amp;buf, &amp;len);</span>
<span class="lineNum">      57 </span>        [<span class="branchCov" title="Branch 0 was taken 2 times"> + </span><span class="branchNoCov" title="Branch 1 was not taken"> - </span>]:<span class="lineCov">          2 :         if (rv == APR_EOF) {</span>
<span class="lineNum">      58 </span>                :<span class="lineCov">          2 :             *atreadeof = 1;</span>
<span class="lineNum">      59 </span>                :<span class="lineCov">          2 :             return APR_SUCCESS;</span>
<span class="lineNum">      60 </span>                :            :         }
<span class="lineNum">      61 </span>        [<span class="branchNoExec" title="Branch 0 was not executed"> # </span><span class="branchNoExec" title="Branch 1 was not executed"> # </span>]:<span class="lineNoCov">          0 :         else if (rv) {</span>
<span class="lineNum">      62 </span>                :            :             /* Read error -&gt; unexpected error. */
<span class="lineNum">      63 </span>                :<span class="lineNoCov">          0 :             return rv;</span>
<span class="lineNum">      64 </span>                :            :         }
<span class="lineNum">      65 </span>                :            :         else {
<span class="lineNum">      66 </span>                :<span class="lineNoCov">          0 :             *atreadeof = 0;</span>
<span class="lineNum">      67 </span>                :<span class="lineNoCov">          0 :             return APR_SUCCESS;</span>
<span class="lineNum">      68 </span>                :            :         }
<span class="lineNum">      69 </span>                :            :     }
<span class="lineNum">      70 </span>                :            : 
<span class="lineNum">      71 </span>                :            :     /* Should not fall through here. */
<span class="lineNum">      72 </span>                :<span class="lineCov">          4 :     return APR_EGENERAL;</span>
<span class="lineNum">      73 </span>                :            : }
<span class="lineNum">      74 </span>                :            : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.9</a></td></tr>
  </table>
  <br>

</body>
</html>
